
<body class="iframe">
    <div class="userlist">
        <div class="frame-header">
            <h2><i class="layui-icon">&#xe705;</i>用户管理</h2>
        </div>
        <h4 class="layui-bg-dark frame-title"><i class="layui-icon">&#xe65f;</i>审核列表</h4>
        <div class="toolbox layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 80px;">
                        <input type="checkbox" name="" title="全选" lay-skin="primary" lay-filter='checkall'>
                    </div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <button class="layui-btn layui-btn-normal passall"><i class="layui-icon">&#xe616;</i>通过</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="data-table">
            <table class="layui-table">
                <thead>
                    <tr>
                        <th></th>
                        <th>id</th>
                        <th>部门</th>
                        <th>用户名</th>
                        <th>邮箱</th>
                        <th>注册ip</th>
                        <th>注册时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
        <div id="template-page" class="page"></div>
    </div>
</body>
<script>
    var startpage=0,len=10;
    layui.use(['form', 'laypage', 'layer'], function () {
        var form = layui.form, laypage = layui.laypage, layer = layui.layer;

        getVerifyList(startpage, len);
        laypage.render({
            elem: 'template-page'
            , count: "<?= $sumRecords ?>" //数据总数，从服务端得到
            , theme: '#01AAED'
            , limit: len
            , jump: function (obj, first) {
                page = obj.curr - 1;
                len = obj.limit;
                if (!first) {
                    startpage = page;
                    getVerifyList(startpage, len);
                }
            }
        });
        
        
        


        //全选特效
        form.on('checkbox(checkall)', function (data) {
            let checkstate = data.elem.checked;//全选状态
            $("td input[type=checkbox]").prop('checked', checkstate);
        });

        $(document).on('click', 'td input[type=checkbox]', function () {
            let len = $("td input[type=checkbox]").length;
            let clen = 0;
            $("td input[type=checkbox]:checked").each(function () {
                clen++;
            });
            let state = len == clen ? true : false;
            if (state) {
                $(".checkall").prop('checked', true);
                $(".layui-unselect").addClass("layui-form-checked");
            } else {
                $(".checkall").prop('checked', false);
                $(".layui-unselect").removeClass("layui-form-checked");
            }
        })
        //全选审核
        $(".passall").on('click', function () {
            //被选中的元素集合
            let url = '<?=site_url('member/verify_member')?>';
            let ids = getCheckedItems();
            let jsonData = {
                'ids':ids,
                'state':1
            };
            ids.length == 0 ? layer.msg('请选择需要审核项!') : paramsRequest(url, jsonData, layer, getVerifyList, page, len);
            
        })
        

        
         $(document).on('click', '.verify', function () {
            let url = '<?=site_url('member/verify_member')?>';
            let ids = getId($(this));
            let state = $(this).attr('verify');
            let jsonData = {
                'ids':ids,
                'state':state
            };
            paramsRequest(url, jsonData, layer, getVerifyList, page, len);
        });

    });
    function getVerifyList(page,limit) {
        let url = "<?= site_url('Member/get_verify_list') ?>";
        let jsonData = {
            'page':page,
            'limit':limit
        }
        $.get(url, function (redata) {
            let str = '';
            if (redata.errno == '666') {
                for (x in redata.verifylist) {
                    let num = parseInt(x) + 1;
                    str += '<tr tid="' + redata.verifylist[x].id + '"><td><input type="checkbox" /></td><td>' + num + '</td><td>' + redata.verifylist[x].department_name + '</td><th>' + redata.verifylist[x].username + '</th><td>' + redata.verifylist[x].email + '</td><td>' + redata.verifylist[x].register_ip + '</td><td>' + redata.verifylist[x].register_time + '</td><td><div class="layui-btn-group"><button class="layui-btn layui-btn-normal layui-btn-xs verify" verify="1"><i class="layui-icon">&#xe616;</i>通过</button><button class="layui-btn layui-btn-warm layui-btn-xs verify" verify="2"><i class="layui-icon">&#x1007;</i>拒绝</button></div></td></tr>';
                }
                $(".data-table tbody").html(str);
            } else {
                layer.msg(redata.error);
                $(".data-table tbody").html(str);
            }
        }, 'json');
    }
</script>

</html>